﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows;
using ReporterControlLibrary.Models;

namespace Reporter.Controls
{
    public class ReportLogDataTemplateSelector : DataTemplateSelector
    {
        public DataTemplate ErrorTemplate
        {
            get;
            set;
        }

        public DataTemplate WarningTemplate
        {
            get;
            set;
        }

        public DataTemplate InfoTemplate
        {
            get;
            set;
        }

        public DataTemplate UndefinedTemplate
        {
            get;
            set;
        }

        public override System.Windows.DataTemplate SelectTemplate(object item, System.Windows.DependencyObject container)
        {
            var log = item as ReportLog;
            var logtype = (LogType)log.Type;

            switch (logtype)
            {
                case LogType.Error: return ErrorTemplate;
                case LogType.Warning: return WarningTemplate;
                case LogType.Info: return InfoTemplate;
                case LogType.Undefined: return UndefinedTemplate;
            }

            return UndefinedTemplate;
        }
    }
}
